<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2015-11-2
 * Time: 9:05
 */
require_once 'C:\xampp\htdocs\laravel\PhpWord\Autoloader.php';
\PhpOffice\PhpWord\Autoloader::register();

try {
    $templateProcessor = new \PhpOffice\PhpWord\TemplateProcessor('stapl.docx');

    $templateProcessor->setValue('NO','201511031044');
    $templateProcessor->setValue('NAME','林下鸡的山地养殖技术');
    $templateProcessor->setValue('UNIT','乐山师范学院生物科学学院');
    $templateProcessor->setValue('HEAD','胡丹');
    $templateProcessor->setValue('UNIT2','乐山师范学院');
    $templateProcessor->setValue('YEAR','2015');
    $templateProcessor->setValue('MONTH','11');
    $templateProcessor->setValue('DAY','2');
    $templateProcessor->saveAs('stapl2.docx');
    echo 'Successful!';
} catch (Exception $e)
{
    echo 'Failed!:'.$e->getMessage();
}